package com.shop2cn.iapi.couponmanage.testcase;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.coupon.service.UserReceiveCouponCall;
import com.shop2cn.iapi.couponmanage.parameter.GetSellerBatchesByPagingBean;
import com.shop2cn.iapi.couponmanage.parameter.SellerCreateBatchBean;
import com.shop2cn.iapi.couponmanage.parameter.batchinfo3;
import com.shop2cn.iapi.couponmanage.service.GetSellerBatchesByPagingCall;
import com.shop2cn.iapi.couponmanage.service.SellerCreateBatchCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CouponShop2cnMCallService;
import com.ymttest.database.model.CouponShop2cn.couponbatch;
import com.ymttest.database.sqlwapper.CouponShop2cn.couponbatchWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
/**
*分页获取商家优惠券批次信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetSellerBatchesByPaging{
	private static GetSellerBatchesByPagingBean getsellerbatchesbypagingBean;
	private static GetSellerBatchesByPagingCall getsellerbatchesbypagingCall;
	private static SellerCreateBatchBean sellercreatebatchBean=new SellerCreateBatchBean();;
	private static SellerCreateBatchCall sellercreatebatchCall=new SellerCreateBatchCall(); 
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("分页获取商家优惠券批次信息");
	}

	@Before
	public void caseUp() {
		getsellerbatchesbypagingBean=new GetSellerBatchesByPagingBean();
		getsellerbatchesbypagingCall=new GetSellerBatchesByPagingCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getsellerbatchesbypagingCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_001() {
		Logger.start(true,"根据商家获取批次列表信息-0-全部");
		try {
			Map batch = new couponbatchWapper().getTop1SellerCouponInfo().get(0);
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("OperatorId").toString()));
			
			getsellerbatchesbypagingBean.setBatchStatus(0);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_002() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-1-未领取的优惠券");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();
			Date dvalidStar = new Date();
			Date dvalidEnd = new Date();
			
			Calendar calendar1 = Calendar.getInstance(); 
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 1); 
			dBefore = calendar1.getTime(); 

			Calendar calendar2 = Calendar.getInstance(); 
			calendar2.setTime(dNow);
			calendar2.add(Calendar.DAY_OF_MONTH, 2); 
			dAfter = calendar2.getTime(); 
			
			Calendar calendar3 = Calendar.getInstance(); 
			calendar3.setTime(dNow);
			calendar3.add(Calendar.DAY_OF_MONTH, 1); 
			dvalidStar = calendar3.getTime(); 
			
			Calendar calendar4 = Calendar.getInstance(); 
			calendar4.setTime(dNow);
			calendar4.add(Calendar.DAY_OF_MONTH, 10); 
			dvalidEnd = calendar4.getTime(); 
			
			sellercreatebatchBean.setAcquireStartTime(dBefore);
			sellercreatebatchBean.setAcquireEndTime(dAfter);
			
			sellercreatebatchBean.setEffectiveStartDate(dvalidStar);
			sellercreatebatchBean.setEffectiveEndDate(dvalidEnd);
			new CouponShop2cnMCallService();
			CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        	 
		        	 Map item = new couponbatchWapper().getCouponBatchByBatchCode(batchCode).get(0);
		        	
		        	Logger.verifyEquals(sellerId, Integer.parseInt(item.get("OperatorId").toString()), "验证OperatorId");
		        			        
		        }	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_002_1() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-2-未开始使用");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();
			Date dvalidStar = new Date();
			Date dvalidEnd = new Date();
			Date updateDate = new Date();//需要手动更改的时间
			
			Calendar calendar1 = Calendar.getInstance(); 
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -10); 
			dBefore = calendar1.getTime(); 

			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 1); 
			dAfter = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 1); 
			dvalidStar = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 10); 
			dvalidEnd = calendar1.getTime(); 
			
			sellercreatebatchBean.setAcquireStartTime(dBefore);
			sellercreatebatchBean.setAcquireEndTime(dAfter);
			
			sellercreatebatchBean.setEffectiveStartDate(dvalidStar);
			sellercreatebatchBean.setEffectiveEndDate(dvalidEnd);
			new CouponShop2cnMCallService();
			SellerCreateBatchCall batchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -1); 
			updateDate = calendar1.getTime(); 
			 new couponbatchWapper().setAcquireEndTime(batchCall.getBatchCode(), updateDate);
			
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(2);
			getsellerbatchesbypagingBean.setPageIndex(1); 
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_002_2() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-3-发放中");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();
			Date dvalidStar = new Date();
			Date dvalidEnd = new Date();
			Date updateDate = new Date();//需要手动更改的时间
			
			Calendar calendar1 = Calendar.getInstance(); 
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -10); 
			dBefore = calendar1.getTime(); 

			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 1); 
			dAfter = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 2); 
			dvalidStar = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 10); 
			dvalidEnd = calendar1.getTime(); 
			
			sellercreatebatchBean.setAcquireStartTime(dBefore);
			sellercreatebatchBean.setAcquireEndTime(dAfter);
			
			sellercreatebatchBean.setEffectiveStartDate(dvalidStar);
			sellercreatebatchBean.setEffectiveEndDate(dvalidEnd);
			new CouponShop2cnMCallService();
			SellerCreateBatchCall batchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(3);
			getsellerbatchesbypagingBean.setPageIndex(1); 
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_002_3() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-4-使用中");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();
			Date dvalidStar = new Date();
			Date dvalidEnd = new Date();
			Date updateDate = new Date();//需要手动更改的时间
			
			Calendar calendar1 = Calendar.getInstance(); 
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -10); 
			dBefore = calendar1.getTime(); 

			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 1); 
			dAfter = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -1); 
			dvalidStar = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 10); 
			dvalidEnd = calendar1.getTime(); 
			
			sellercreatebatchBean.setAcquireStartTime(dBefore);
			sellercreatebatchBean.setAcquireEndTime(dAfter);
			
			sellercreatebatchBean.setEffectiveStartDate(dvalidStar);
			sellercreatebatchBean.setEffectiveEndDate(dvalidEnd);
			new CouponShop2cnMCallService();
			SellerCreateBatchCall batchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(4);
			getsellerbatchesbypagingBean.setPageIndex(1); 
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_002_4() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-5-已结束");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
	
			new CouponShop2cnMCallService();
			SellerCreateBatchCall batchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();
			Date dvalidStar = new Date();
			Date dvalidEnd = new Date();
			Date updateDate = new Date();//需要手动更改的时间
			
			Calendar calendar1 = Calendar.getInstance(); 
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -10); 
			dBefore = calendar1.getTime(); 

			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -9); 
			dAfter = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -8); 
			dvalidStar = calendar1.getTime(); 
			
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, -7); 
			dvalidEnd = calendar1.getTime(); 
			
			couponbatch batch = new couponbatchWapper().selectBybatchCode(batchCall.getBatchCode()).get(0);
			
			new couponbatchWapper().setAcquireStartTime(batchCall.getBatchCode(), dBefore);
			new couponbatchWapper().setAcquireEndTime(batchCall.getBatchCode(), dAfter);
			new couponbatchWapper().setValidStart(batch.getBatchId(), dvalidStar);
			new couponbatchWapper().setValidEnd(batch.getBatchId(), dvalidEnd);
			
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(5);
			getsellerbatchesbypagingBean.setPageIndex(1); 
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_004() {
		Logger.start(true,"根据有效期获取商家优惠券批次列表信息");
		try {
			
			Map batch = new couponbatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("OperatorId").toString()));	
			
			//int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			
			//getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(0);
			
			Date dNow = new Date(); // 当前时间
	        Date dBefore = new Date();
	        Date dAfter = new Date();

	        Calendar calendar1 = Calendar.getInstance(); // 得到日历
	        calendar1.setTime(dNow);// 把当前时间赋给日历
	        calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
	        dBefore = calendar1.getTime(); // 得到前一天的时间

	        Calendar calendar2 = Calendar.getInstance(); // 得到日历
	        calendar2.setTime(dNow);// 把当前时间赋给日历
	        calendar2.add(Calendar.DAY_OF_MONTH, 10); // 设置为后十天
	        dAfter = calendar2.getTime(); // 得到前一天的时间
		        
		        
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();			
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("操作成功！", getsellerbatchesbypagingCall.getMessage(), "验证返回Message");

			verifyReturn();
			
//			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
//			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
//  
//		        for(int i=0;i<batchList.size();i++)
//		        {
//		        	 String batchCode = batchList.get(i).getBatchCode();
//		        	 batchinfo3 batchInfo = batchList.get(i);
//		        	 
//		        	 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
//		        	 
//		        	 Date startTime=sdf.parse(sdf.format(YMTDateUtil.getDateFromReturn(batchInfo.getEffectiveStartTime())));
//		        	 Date endTime=sdf.parse(sdf.format(YMTDateUtil.getDateFromReturn(batchInfo.getEffectiveEndTime())));
//				        
//		        	 Date d1=sdf.parse(sdf.format(dBefore)); 
//		        	 Date d2=sdf.parse(sdf.format(dAfter));
//		        	 
//
//		        	 Logger.comment("传入时间区间：");
//		        	 Logger.comment(sdf.format(d1));
//		        	 Logger.comment(sdf.format(d2));
//		        	 
//		        	 Logger.comment("返回时间区间：");
//		        	 Logger.comment(sdf.format(startTime));
//		        	 Logger.comment(sdf.format(endTime));
//		        	 
//		        	Logger.verifyEquals(false, startTime.after(d2)||endTime.before(d1), "验证effectiveStartTime");		        
//		        }	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_005() {
		Logger.start(true,"根据商家获取批次列表信息-优惠券状态 BatchStatus=10");
		try {
			Map batch = new couponbatchWapper().getTop1SellerCouponInfo().get(0);
			
			getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("OperatorId").toString()));
			getsellerbatchesbypagingBean.setBatchStatus(99999999);//不存在
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("1", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals(true, getsellerbatchesbypagingCall.getMessage().contains("批次状态的输入值不对"), "验证返回Message");
//
//			verifyReturn();	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_006() {
		Logger.start(true,"根据商家获取批次列表信息-SellerId为空");
		try {
			Map batch = new couponbatchWapper().getTop1SellerCouponInfo().get(0);
			
			//getsellerbatchesbypagingBean.setSellerId(Integer.parseInt(batch.get("OperatorId").toString()));
			getsellerbatchesbypagingBean.setBatchStatus(0);//不存在
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("1", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getRecordCount(), "验证返回RecordCount");
			Logger.verifyEquals(true, getsellerbatchesbypagingCall.getErrorMessage().contains("请传入商家编号"), "验证返回SellerId");
//
//			verifyReturn();	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_007() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-作废-不显示作废");
		try {
			Logger.comment("####### 创建领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			new CouponShop2cnMCallService();
			SellerCreateBatchCall sellerCreateBatchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			int sellerId = sellercreatebatchBean.getSellerId();
			Logger.comment("####### 创建领取的优惠券 结束########");
			
			new CouponShop2cnMCallService().InvalidSellerBatch(sellerId, sellerCreateBatchCall.getBatchCode());
			
		
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setShowInvalidBatches(false);
			getsellerbatchesbypagingBean.setBatchStatus(1);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getRecordCount(), "验证返回RecordCount");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_008() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息- 未领取的优惠券和作废，传入作废");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			Date dNow = new Date(); // 当前时间
			Date dBefore = new Date();
			Date dAfter = new Date();
			Date dvalidStar = new Date();
			Date dvalidEnd = new Date();
			
			Calendar calendar1 = Calendar.getInstance(); 
			calendar1.setTime(dNow);
			calendar1.add(Calendar.DAY_OF_MONTH, 1); 
			dBefore = calendar1.getTime(); 

			Calendar calendar2 = Calendar.getInstance(); 
			calendar2.setTime(dNow);
			calendar2.add(Calendar.DAY_OF_MONTH, 2); 
			dAfter = calendar2.getTime(); 
			
			Calendar calendar3 = Calendar.getInstance(); 
			calendar3.setTime(dNow);
			calendar3.add(Calendar.DAY_OF_MONTH, 1); 
			dvalidStar = calendar3.getTime(); 
			
			Calendar calendar4 = Calendar.getInstance(); 
			calendar4.setTime(dNow);
			calendar4.add(Calendar.DAY_OF_MONTH, 10); 
			dvalidEnd = calendar4.getTime(); 
			
			sellercreatebatchBean.setAcquireStartTime(dBefore);
			sellercreatebatchBean.setAcquireEndTime(dAfter);
			
			sellercreatebatchBean.setEffectiveStartDate(dvalidStar);
			sellercreatebatchBean.setEffectiveEndDate(dvalidEnd);
			new CouponShop2cnMCallService();
			CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			
			Logger.comment("####### 创建领取的优惠券 开始########");
			new CouponShop2cnMCallService();
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			sellercreatebatchBean.setSellerId(sellerId);
			new CouponShop2cnMCallService();
			SellerCreateBatchCall sellerCreateBatchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);

			Logger.comment("####### 创建领取的优惠券 结束########");
			
			new CouponShop2cnMCallService().InvalidSellerBatch(sellerId, sellerCreateBatchCall.getBatchCode());
			
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(0);
			getsellerbatchesbypagingBean.setShowInvalidBatches(false);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        	 
		        	 Map item = new couponbatchWapper().getCouponBatchByBatchCode(batchCode).get(0);
		        	
		        	Logger.verifyEquals(sellerId, Integer.parseInt(item.get("OperatorId").toString()), "验证OperatorId");
		        			        
		        }	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSellerBatchesByPaging_009() {
		Logger.start(true,"根据优惠券编号获取优惠券批次列表信息-正常优惠券和作废，传入作废");
		try {
			Logger.comment("####### 创建未领取的优惠券 开始########");
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);
			Logger.comment("####### 创建未领取的优惠券 结束########");
			
			int sellerId = sellercreatebatchBean.getSellerId();
			
			Logger.comment("####### 创建领取的优惠券 开始########");
			sellercreatebatchBean = CouponShop2cnMCallService.setDefaultSellerCreateBatchBean();
			sellercreatebatchBean.setSellerId(sellerId);
			SellerCreateBatchCall sellerCreateBatchCall=CouponShop2cnMCallService.SellerCreateBatch(sellercreatebatchBean);

			Logger.comment("####### 创建领取的优惠券 结束########");
			new CouponShop2cnMCallService().InvalidSellerBatch(sellerId, sellerCreateBatchCall.getBatchCode());
			getsellerbatchesbypagingBean.setSellerId(sellerId);
			getsellerbatchesbypagingBean.setBatchStatus(0);
			getsellerbatchesbypagingBean.setShowInvalidBatches(false);
			getsellerbatchesbypagingBean.setPageIndex(1);
			getsellerbatchesbypagingBean.setPageSize(10);
			getsellerbatchesbypagingCall.setData(getsellerbatchesbypagingBean);
			getsellerbatchesbypagingCall.callService();		
			
			Logger.verifyEquals("0", getsellerbatchesbypagingCall.getCode(), "验证返回code");

			verifyReturn();
			
			List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回Message");
  
		        for(int i=0;i<batchList.size();i++)
		        {
		        	 String batchCode = batchList.get(i).getBatchCode();
		        	 batchinfo3 batchInfo = batchList.get(i);
		        	 
		        	 Map item = new couponbatchWapper().getCouponBatchByBatchCode(batchCode).get(0);
		        	
		        	Logger.verifyEquals(sellerId, Integer.parseInt(item.get("OperatorId").toString()), "验证OperatorId");
		        			        
		        }	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	private void verifyReturn()
	{
			 List<batchinfo3> batchList = getsellerbatchesbypagingCall.getbatchInfos().getBatchInfos();
			 Logger.verifyEquals(true, Integer.parseInt(getsellerbatchesbypagingCall.getRecordCount())>0, "验证返回RecordCoun");
	        for(int i=0;i<batchList.size();i++)
	        {
	        	 String batchCode = batchList.get(i).getBatchCode();
	        	 batchinfo3 batchInfo = batchList.get(i);
	        	 
	        	 Map item = new couponbatchWapper().getCouponBatchByBatchCode(batchCode).get(0);

	        	 Logger.verifyEquals(getsellerbatchesbypagingBean.getSellerId(), Integer.parseInt(item.get("OperatorId").toString()), "验证OperatorId");
	        	 
	             Logger.verifyEquals(Integer.parseInt(item.get("BatchId").toString()),
	             		batchInfo.getBatchId(),
	                     "验证返回BatchCode与数据库中表CouponBatch中BatchCode=" + batchCode
	                             + "记录中BatchId字段相同");
	             
	             Logger.verifyEquals(item.get("BatchCode").toString(),
	             		batchInfo.getBatchCode(),
	                     "验证返回BatchCode与数据库中表CouponBatch中BatchCode=" + batchCode
	                             + "记录中BatchCode字段相同");

	             Logger.verifyEquals(item.get("CouponName").toString(),
		             		batchInfo.getBatchName(),
		                     "验证返回BatchCode与数据库中表CouponBatch中BatchCode=" + batchCode
		                             + "记录中CouponName字段相同");
	          
	             Logger.verifyEquals(item.get("ValidStart").toString().subSequence(0, 19),
	             		batchInfo.getEffectiveStartTime().replace("T", " "),
	                     "验证返回dValidStart与数据库中表CouponSetting中ValidStart字段相同");

	             Logger.verifyEquals(item.get("ValidEnd").toString().subSequence(0, 19),
	             		batchInfo.getEffectiveEndTime().replace("T", " "),
	                     "验证返回dValidEnd与数据库中表Ymt_CouponSetting中ValidEnd字段相同");
	             
	             Logger.verifyEquals(Boolean.parseBoolean(item.get("IsShowInPage").toString()),
		             		batchInfo.isShowInPage(),
		                     "验证返回isShowInPage与数据库中表Ymt_CouponBatch中isShowInPage字段相同");
		           
	             Logger.verifyEquals(Boolean.parseBoolean(item.get("IsInvalid").toString()),
		             		batchInfo.isInvalid(),
		                     "验证返回IsInvalid与数据库中表CouponBatch中IsInvalid字段相同");
	             
	             Logger.verifyEquals(Integer.parseInt(item.get("TotalNum").toString()),
		             		batchInfo.getCouponTotalNum(),
		                     "验证返回CouponTotalNum与数据库中表CouponBatch中TotalNum字段相同");
	             
	             Logger.verifyEquals(Integer.parseInt(item.get("ReceivedCount").toString()),
		             		batchInfo.getReceivedCount(),
		                     "验证返回ReceivedCount与数据库中表CouponBatch中ReceivedCount字段相同");
		
	            // Integer CouponType=Integer.parseInt(item.get("AcquireMethod").toString())==3?2:1;
	             Logger.verifyEquals(Byte.parseByte(item.get("CouponType").toString()),
		             		batchInfo.getCouponType(),
		                     "验证返回BatchCode与数据库中表CouponBatch中BatchCode=" + batchCode
		                             + "记录中coupontype字段相同");
	             
	              //新增验证
	             Logger.verifyEquals(item.get("AcquireStartTime").toString().subSequence(0, 19),
		             		batchInfo.getAcquireStartTime().replace("T", " "),
		                     "验证返回acquireStartTime与数据库couponbatch字段acquireStartTime是否一致");
	             
	             Logger.verifyEquals(item.get("AcquireEndTime").toString().subSequence(0, 19),
		             		batchInfo.getAcquireEndTime().replace("T", " "),
		                     "验证返回acquireEndTime与数据库couponbatch字段acquireEndTime是否一致");
	             
	             Logger.verifyEquals(item.get("CouponTypeBizValue").toString(),
		             		batchInfo.getCouponTypeBizValue(),
		                     "验证返回couponTypeBizValue与数据库couponbatch字段couponTypeBizValue是否一致");
	             //新增参数
	             Logger.verifyEquals(item.get("Currency").toString(),batchInfo.getCurrency(),
		                     "验证返回Currency与数据库couponbatch字段Currency是否一致");
	             Logger.verifyEquals(item.get("UseConditionType").toString(),batchInfo.getUseConditionType(),
		                     "验证返回UseConditionType与数据库couponbatch字段UseConditionType是否一致");
	             
	             Logger.verifyEquals(Integer.parseInt(item.get("UsedCount").toString()),batchInfo.getUsedCount(),
	                     "验证返回UseConditionType与数据库couponbatch字段UseConditionType是否一致");
	             
	        }
	}
}